package com.example.mybatisplus.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.mybatisplus.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2025-01-22
 * Time: 22:46
 */
@Mapper
public interface UserInfoMapper extends BaseMapper<UserInfo> {
    @Select("select id,username,password,age from user_info where username = #{name}")
    List<UserInfo> selectByCustom(String name);

    @Select("select id,username,password,age from user_info ${ew.customSqlSegment}")
    List<UserInfo> selectByCustom1(@Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);

    @Select("select id,username,password,age from user_info ${ew.customSqlSegment}")
    List<UserInfo> selectByCustom2(@Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);

    @Update("update user_info set age = age +#{age} ${ew.customSqlSegment}")
    Integer updateByCustom(@Param("age")Integer age,@Param(Constants.WRAPPER) Wrapper<UserInfo> wrapper);
}
